package cn.tedu.user.management.dao.persist.repository.impl;

import cn.tedu.user.management.dao.persist.mapper.MaintainMapper;
import cn.tedu.user.management.dao.persist.repository.IMaintainRepository;
import cn.tedu.user.management.pojo.entity.Maintain;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository
public class MaintainRepositoryImpl implements IMaintainRepository {

    @Autowired
    MaintainMapper maintainMapper;
    @Override
    public int deleteByUserId(Long id) {
        log.debug("开始执行【根据user_id删除维修记录】的操作，参数：{}", id);
        return maintainMapper.deleteByUserId(id);
    }

    @Override
    public int countByUserId(Long id) {
        log.debug("开始执行【根据user_id统计维修记录的数量】的数据访问，参数：{}", id);
        QueryWrapper<Maintain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        return maintainMapper.selectCount(queryWrapper);
    }
}
